/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Logico;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author usuario
 */
@Entity
@Table(name = "deportista_competencia")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DeportistaCompetencia.findAll", query = "SELECT d FROM DeportistaCompetencia d"),
    @NamedQuery(name = "DeportistaCompetencia.findByIdcompetencia", query = "SELECT d FROM DeportistaCompetencia d WHERE d.deportistaCompetenciaPK.idcompetencia = :idcompetencia"),
    @NamedQuery(name = "DeportistaCompetencia.findByIddeportista", query = "SELECT d FROM DeportistaCompetencia d WHERE d.deportistaCompetenciaPK.iddeportista = :iddeportista"),
    @NamedQuery(name = "DeportistaCompetencia.findByFase", query = "SELECT d FROM DeportistaCompetencia d WHERE d.deportistaCompetenciaPK.fase = :fase"),
    @NamedQuery(name = "DeportistaCompetencia.findByPuntaje", query = "SELECT d FROM DeportistaCompetencia d WHERE d.puntaje = :puntaje")})
public class DeportistaCompetencia implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DeportistaCompetenciaPK deportistaCompetenciaPK;
    @Column(name = "puntaje")
    private Integer puntaje;
    @JoinColumn(name = "iddeportista", referencedColumnName = "cedula", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Deportista deportista;
    @JoinColumn(name = "idcompetencia", referencedColumnName = "idcompetencia", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Competencia competencia;

    public DeportistaCompetencia() {
    }

    public DeportistaCompetencia(DeportistaCompetenciaPK deportistaCompetenciaPK) {
        this.deportistaCompetenciaPK = deportistaCompetenciaPK;
    }

    public DeportistaCompetencia(int idcompetencia, int iddeportista, String fase) {
        this.deportistaCompetenciaPK = new DeportistaCompetenciaPK(idcompetencia, iddeportista, fase);
    }

    public DeportistaCompetenciaPK getDeportistaCompetenciaPK() {
        return deportistaCompetenciaPK;
    }

    public void setDeportistaCompetenciaPK(DeportistaCompetenciaPK deportistaCompetenciaPK) {
        this.deportistaCompetenciaPK = deportistaCompetenciaPK;
    }

    public Integer getPuntaje() {
        return puntaje;
    }

    public void setPuntaje(Integer puntaje) {
        this.puntaje = puntaje;
    }

    public Deportista getDeportista() {
        return deportista;
    }

    public void setDeportista(Deportista deportista) {
        this.deportista = deportista;
    }

    public Competencia getCompetencia() {
        return competencia;
    }

    public void setCompetencia(Competencia competencia) {
        this.competencia = competencia;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (deportistaCompetenciaPK != null ? deportistaCompetenciaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DeportistaCompetencia)) {
            return false;
        }
        DeportistaCompetencia other = (DeportistaCompetencia) object;
        if ((this.deportistaCompetenciaPK == null && other.deportistaCompetenciaPK != null) || (this.deportistaCompetenciaPK != null && !this.deportistaCompetenciaPK.equals(other.deportistaCompetenciaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Logico.DeportistaCompetencia[ deportistaCompetenciaPK=" + deportistaCompetenciaPK + " ]";
    }
    
}
